#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/6/4 17:59
# @Author : 闫峰
# @File    : zhcxkj_center_order.py
from typing import Optional

from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database

zhcxkj_center_order_db = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"),
                                                          "HWY-ZH-GZ-RDS-JavaCommon")


class ZhcxkjCenterOrder:

    @staticmethod
    def get_sales_num_by_order_source_sku(order_source_id,order_source_sku):

        # 构造SQL查询语句，用于从综合列表数据库中分批获取产品信息
        filter = """
        SELECT
         sum(sales_num)
        FROM
        	zhcxkj_center_order.rb_report_order_source_sku_year 
        WHERE
        	 order_source_id = %s
        	 	AND order_source_sku = %s
        	group by order_source_id,order_source_sku
            """
        data_list = zhcxkj_center_order_db.fetch_all_tuple(filter, (order_source_id,order_source_sku))
        if not len(data_list):
            return 0
        return data_list[0][0]